@extends('admin::layouts.master')
@section('content')

    <div class="card" id="app">
        <div class="card-header">货物管理</div>
        <div class="tab-container">
            <ul role="tablist" class="nav nav-tabs">
                <li class="nav-item"><a href="/buy/huowu/{{$good->id}}" class="nav-link active">货物列表</a></li>
                <li class="nav-item"><a href="/buy/huowu/create/{{$good->id}}" class="nav-link">添加货物</a></li>
            </ul>
            <div class="card card-contrast card-border-color-success">
                <div class="card-body">
                    <table class="table">
                        <thead>
                        <tr>
                            <th style="width: 10%;">编号</th>
                            <th>货物属性</th><th>货物库存</th><th>附加价格</th>
                            <th>创建时间</th>
                            <th>修改时间</th>
                            <th>&nbsp;</th>
                        </tr>
                        </thead>
                        <tbody>
                        @foreach($data as $d)

                            <tr>
                                <td>{!! $d['id'] !!}</td>
                                <td>{!! $d['attr'] !!}</td><td>{!! $d['kucun'] !!}</td><td>{!! $d['fujiaprice'] !!}</td>
                                <td>{!! $d['created_at'] !!}</td>
                                <td>{!! $d['updated_at'] !!}</td>
                                <td class="text-right">
                                    <a href="/buy/huowu/edit/{{$good->id}}/{{$d->id}}" class="btn btn-secondary">编辑</a>
                                    <button type="button" class="btn btn-secondary btn-danger" onclick="del({{$d['id']}},this)">删除</button>
                                    <form action="/buy/huowu/{{$d->id}}" hidden method="post">
                                        @csrf @method('DELETE')
                                    </form>
                                </td>
                            </tr>
                           
                        @endforeach
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <div class="float-right">
        {!!  $data->links() !!}
    </div>
@endsection
@section('script')
    <script>
        function del(id, el) {
            if (confirm('确定删除吗？')) {
                $(el).next('form').trigger('submit')
            }
        }
    </script>
@endsection
